package vfs.common.command.remote;

import vfs.common.Locale;
import vfs.common.command.AbstractCommand;
import vfs.common.file.VirtualFileNotFoundException;

/**
 * User: serge
 * Date: 22.11.13
 * Time: 5:43
 */
public class ChangeDirCommand extends AbstractCommand implements RemoteCommand
{
    @Override
    public void execute()
    {
        checkFilesystem();
        checkUser();
        checkTty();

        if (params.length != 2)
        {
            tty.broadcast(Locale.CMD_EXC_WRONG_PARAMS, user);
        }

        String path = params[1];

        try
        {
            filesystem.changeDir(user, path);
            tty.send("Changed OK", user);
        }
        catch (VirtualFileNotFoundException e)
        {
//            e.printStackTrace();
            tty.send("Path not found", user);
        }
    }
}
